<!DOCTYPE html>
<html lang="zh-cn"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="referrer" content="never">
    <meta name="description" content="WebService、soap、gsoap基本概念 WebService服务基本概念：就是一个应用程序，它向外界暴露出一个可以通过web进行调用的API，是分布式的服务组件。本质上就是要以标准的形式实">
    <meta property="og:description" content="WebService、soap、gsoap基本概念 WebService服务基本概念：就是一个应用程序，它向外界暴露出一个可以通过web进行调用的API，是分布式的服务组件。本质上就是要以标准的形式实">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>gsoap使用总结 - 苦涩的茶 - 博客园</title>
    <link id="favicon" rel="shortcut icon" href="https://common.cnblogs.com/favicon.svg" type="image/svg+xml">
    
    <link rel="stylesheet" href="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/blog-common.css">
    <link id="MainCss" rel="stylesheet" href="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/bundle-sea.css">
    <link type="text/css" rel="stylesheet" href="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/cnblogs.css">
    
    <link id="mobile-style" media="only screen and (max-width: 767px)" type="text/css" rel="stylesheet" href="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/bundle-sea-mobile.css">
    
    <link type="application/rss+xml" rel="alternate" href="https://www.cnblogs.com/liushui-sky/rss">
    <link type="application/rsd+xml" rel="EditURI" href="https://www.cnblogs.com/liushui-sky/rsd.xml">
    <link type="application/wlwmanifest+xml" rel="wlwmanifest" href="https://www.cnblogs.com/liushui-sky/wlwmanifest.xml">
    <script async="" src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/analytics.js"></script><script>
        var currentBlogId = 101800;
        var currentBlogApp = 'liushui-sky';
        var cb_enable_mathjax = false;
        var isLogined = false;
        var isBlogOwner = false;
        var skinName = 'sea';
        var visitorUserId = '';
        var hasCustomScript = false;
        try {
            if (hasCustomScript && document.referrer && document.referrer.indexOf('baidu.com') >= 0) {
                Object.defineProperty(document, 'referrer', { value: '' });
                Object.defineProperty(Document.prototype, 'referrer', { get: function(){ return ''; } });
            }
        } catch(error) { }
    </script>
        <script>
            var currentPostDateAdded = '2018-09-29 02:07';
        </script>
    <script src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/jquery-2.js"></script>
    <script src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/blog-common.js"></script><style type="text/css">.medium-zoom-overlay{position:fixed;top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .3s;will-change:opacity}.medium-zoom--opened .medium-zoom-overlay{cursor:pointer;cursor:zoom-out;opacity:1}.medium-zoom-image{cursor:pointer;cursor:zoom-in;transition:transform .3s cubic-bezier(.2,0,.2,1)!important}.medium-zoom-image--hidden{visibility:hidden}.medium-zoom-image--opened{position:relative;cursor:pointer;cursor:zoom-out;will-change:transform}</style>
    
    
    
     <script type="text/javascript">
        window.codeHighlightEngine = 1
        window.enableCodeLineNumber = false
     </script>
</head>
<body class="skin-sea has-navbar">
    <a name="top"></a>
    <div id="top_nav" class="navbar forpc">
        <nav id="nav_main" class="navbar-main">
            <ul id="nav_left" class="navbar-list navbar-left">
                <li class="navbar-branding"><a href="https://www.cnblogs.com/" title="开发者的网上家园"><img src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/logo.svg" alt="博客园Logo"></a></li>
                <li><a href="https://www.cnblogs.com/" onclick="ga('send', 'event', 'Link', 'click', 'skin-navbar-sitehome')">首页</a></li>
                <li><a href="https://news.cnblogs.com/" onclick="ga('send', 'event', 'Link', 'click', 'skin-navbar-news')">新闻</a></li>
                <li><a href="https://q.cnblogs.com/" onclick="ga('send', 'event', 'Link', 'click', 'skin-navbar-q')">博问</a></li>
                <li><a id="nav_brandzone" href="https://brands.cnblogs.com/" onclick="ga('send', 'event', 'Link', 'click', 'skin-navbar-brands')">专区</a></li>
                <li><a href="https://ing.cnblogs.com/" onclick="ga('send', 'event', 'Link', 'click', 'skin-navbar-ing')">闪存</a></li>
                <li><a href="https://edu.cnblogs.com/" onclick="ga('send', 'event', 'Link', 'click', 'skin-navbar-edu')">班级</a></li>
            </ul>
            <ul id="nav_right" class="navbar-list navbar-right">
                <li>
                    <form id="zzk_search" class="navbar-search" action="https://zzk.cnblogs.com/s" method="get">
                        <input name="w" id="zzk_search_input" placeholder="代码改变世界" type="text" tabindex="3">
                        <button type="submit" id="zzk_search_button">
                            <img src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/search.svg" alt="搜索">
                        </button>
                    </form>
                </li>
                <li id="navbar_login_status" class="navbar-list">
                    <a class="navbar-user-info navbar-blog" href="https://i.cnblogs.com/EditPosts.aspx?opt=1" alt="写随笔" title="写随笔" style="display: none;">
                        <img id="new_post_icon" class="navbar-icon" src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/newpost.svg" alt="写随笔">
                    </a>
                    <a id="navblog-myblog-icon" class="navbar-user-info navbar-blog" href="https://passport.cnblogs.com/GetBlogApplyStatus.aspx" alt="我的博客" title="我的博客" style="display: none;">
                        <img id="myblog_icon" class="navbar-icon" src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/myblog.svg" alt="我的博客">
                    </a>
                    <a class="navbar-user-info navbar-message navbar-icon-wrapper" href="https://msg.cnblogs.com/" alt="短消息" title="短消息" style="display: none;">
                        <img id="msg_icon" class="navbar-icon" src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/message.svg" alt="短消息">
                        <span id="msg_count" style="display: none"></span>
                    </a>
                    <div id="user_info" class="navbar-user-info dropdown" style="display: none;">
                        <a class="dropdown-button" href="https://home.cnblogs.com/">
                            <img id="user_icon" class="navbar-avatar" src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/avatar-default.svg" alt="用户头像">
                        </a>
                        <div class="dropdown-menu">
                            <a id="navblog-myblog-text" href="https://passport.cnblogs.com/GetBlogApplyStatus.aspx">我的博客</a>
                            <a href="https://home.cnblogs.com/">我的园子</a>
                            <a href="https://account.cnblogs.com/settings/account">账号设置</a>
                            <a href="javascript:void(0)" id="navbar_lite_mode_toggle" title="简洁模式会使用简洁款皮肤显示所有博客">
    简洁模式 <img id="navbar_lite_mode_on" src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/lite-mode-check.svg" class="hide"><span id="navbar_lite_mode_spinner" class="hide">...</span>
</a>
                            <a href="javascript:void(0)" onclick="account.logout();">退出登录</a>
                        </div>
                    </div>
                    <a class="navbar-anonymous" href="https://account.cnblogs.com/signup/" style="display: inline;">注册</a>
                    <a class="navbar-anonymous" href="javascript:void(0);" onclick="account.login()" style="display: inline;">登录</a>
                </li>
            </ul>
        </nav>
    </div>

    
    <!--done-->
<div id="header">
	
<!--done-->
<div class="header">
	<div class="headerText">
		<a id="Header1_HeaderTitle" class="headermaintitle HeaderMainTitle" href="https://www.cnblogs.com/liushui-sky/">苦涩的茶</a>
<br>
		——产品开发
	</div>
</div>


</div>

<div id="mytopmenu">
	
		<div id="mylinks">
<a id="blog_nav_sitehome" class="menu" href="https://www.cnblogs.com/">
博客园</a>
 &nbsp;

<a id="blog_nav_myhome" class="menu" href="https://www.cnblogs.com/liushui-sky/">
首页</a>
 &nbsp;


<a id="blog_nav_newpost" class="menu" href="https://i.cnblogs.com/EditPosts.aspx?opt=1">
新随笔</a>
 &nbsp;

<a id="blog_nav_contact" class="menu" href="https://msg.cnblogs.com/send/%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6">
联系</a> &nbsp;


&nbsp;

<a id="blog_nav_admin" class="menu" href="https://i.cnblogs.com/">
管理</a>


</div>
		<div id="mystats">随笔 -
344&nbsp;
文章 -
18&nbsp;
评论 -
66&nbsp;
阅读 - 

<span title="总阅读数: 1487695">
148万</span>
</div>
	
</div>
<div id="centercontent">
	<div id="post_detail">
<div class="post">
	<h1 class="postTitle">
<a id="cb_post_title_url" class="postTitle2 vertical-middle" href="https://www.cnblogs.com/liushui-sky/p/9723397.html">
    <span>gsoap使用总结</span>
    



</a>
</h1>
	<div id="cnblogs_post_body" class="blogpost-body blogpost-body-html">
<h1><a name="_Toc453414525" target="_blank"></a>WebService、soap、gsoap基本概念</h1>
<p>WebService服务基本概念：就是一个应用程序，它向外界暴露出一个可以通过web进行调用的API，是分布式的服务组件。本质上就是要以标准的形式实现企业内外各个不同服务系统之间的互调和集成。</p>
<p>soap概念：简单对象访问协议，是一种轻量的、简单的、基于&nbsp;XML&nbsp;的协议，它被设计成在WEB&nbsp;上交换结构化的和固化的信息。</p>
<p>从这里的概念可以看得出来，soap是一个基于xml格式的web交互协议，而webservice是一种使用web方式实现的功能。就好像是网络
视频服务器和http的关系，就是这里的webservice服务器和soap的关系。其实从历史上来说，先有的soap这种协议，然后微软用基于这种协
议制作了webservice这种服务。</p>
<p>gsoap概念：是一种能够把C/C++语言的接口转换成基于soap协议的webservice服务的工具。</p>
<h1><a name="t1"></a><a name="_Toc453414526" target="_blank"></a>gSOAP简介</h1>
<p>gSOAP是一个开发SOAP和XML应用（它们组成了webservice）的工具，在英文中叫toolkit。它是跨平台的，webservice的客户端和服务器端，都可以用它来辅助开发。它主要的功能（特征）如下：</p>
<ul type="disc">
<li>C/C++数据绑定工具，支持XML-RPCfrom/to JSON from/to C/C++ serialization</li>
<li>支持WSDL 1.1，2.0, SOAP 1.1， 1.2</li>
<li>支持REST HTTP(S) 1.0/1.1 operations (GET,PUT,POST etc) for XML, JSON,etc</li>
<li>支持MIME and MTOM 附件</li>
<li>支持IPv4，IPv6, TCP 和UDP</li>
<li>支持CGI，FastCGI</li>
<li>支持嵌入到Apache，IIS中发布</li>
<li>自带了一个Web server (multithreaded, SSL, compression)用于发布</li>
<li>可适用于WinCE, Palm, Symbian, VxWorks, Andriod, iPhone等小设备</li>
<li>...（拣主要的，其余忽略）</li>
</ul>
<p>gsoap下载地址</p>
<p><a href="http://sourceforge.net/project/showfiles.php?group_id=52781" rel="nofollow" target="_blank">http://sourceforge.net/project/showfiles.php?group_id=52781</a></p>
<p>&nbsp;</p>
<h1><a name="t2"></a><a name="_Toc453414527" target="_blank"></a><a name="t1" target="_blank"></a>gSOAP结构</h1>
<p>目前gSOAP的版本是2.8.12，作者认为，gSOAP的组织结构以及使用的方便性，在开源项目中是比较好的。</p>
<p>在应用中，我们首先要应用它的两个工具： soapcpp2和 
wsdl2h。所幸的是这个两个工具在gSOAP包中已经被编译生成（bin目录下），所以我们只要拿来用即可，gSOAP使用的方便性就体现出来了。另
一个方便性是它的源文件个数较少，如果我们不去研究，少的文件个数包含在我们的工程中，也减少了维护的成本。</p>
<h2><a name="t3"></a><a name="_Toc453414528" target="_blank"></a><a name="t2" target="_blank"></a>1.soapcpp2的用法</h2>
<p>Soapcpp2是一个根据.h文件生成若干支持webservice的代码生成工具，生成的代码文件包括webservice客户端和服务器的实现框架，XML数据绑定等，具体说明如下：</p>
<div class="table-wrapper"><table cellspacing="0" cellpadding="0" border="1">
<tbody>
<tr>
<td>
<p align="center"><strong>文件</strong></p>
</td>
<td>
<p align="center"><strong>描述</strong></p>
</td>
</tr>
<tr>
<td>
<p><em>soapStub.h</em></p>
</td>
<td>
<p>根据输入的.h文件生成的数据定义文件，一般我们不直接引用它。</p>
</td>
</tr>
<tr>
<td>
<p><em>soapH.h</em></p>
<p><em>soapC.cpp</em></p>
</td>
<td>
<p>客户端和服务器端应包含该头文件，它包含了soapStub.h。针对soapStub.h中的数据类型，cpp文件实现了序列化、反序列化方法。</p>
</td>
</tr>
<tr>
<td>
<p><em>soapXYZProxy.h</em></p>
<p><em>soapXYZProxy.cpp</em></p>
</td>
<td>
<p>这两个文件用于客户端，是客户端调用webservice的框架文件，我们的代码主要在此实现或从它继承。</p>
</td>
</tr>
<tr>
<td>
<p><em>soapXYZService.h</em></p>
<p><em>soapXYZService.cpp</em></p>
</td>
<td>
<p>这两个文件用于服务器端，是服务器端实现webservice的框架文件，我们的代码主要在此实现或从它继承。</p>
</td>
</tr>
<tr>
<td>
<p><em>.xsd</em></p>
</td>
<td>
<p>传输消息的schema，，我们可以看看是否满足我们的协议格式（如果有此要求）</p>
</td>
</tr>
<tr>
<td>
<p><em>.wsdl</em></p>
</td>
<td>
<p>这个就不用说了。</p>
</td>
</tr>
<tr>
<td>
<p><em>.xml</em></p>
</td>
<td>
<p>满足webservice定义的例子message,即实际的传输消息，我们可以看看是否满足我们的协议格式（如果有此要求）。</p>
</td>
</tr>
<tr>
<td>
<p><em>.nsmap</em></p>
</td>
<td>
<p>命名空间的定义，对命名空间不敏感的，不用关注。</p>
</td>
</tr>
</tbody>
</table></div>
<p>使用soapcpp2时，可选项如下：</p>
<p>&nbsp;</p>
<div class="table-wrapper"><table cellspacing="0" cellpadding="0" border="1">
<tbody>
<tr>
<td>
<p align="center"><strong>选项</strong></p>
</td>
<td>
<p align="center"><strong>描述</strong></p>
</td>
</tr>
<tr>
<td>
<p><em>-1</em></p>
</td>
<td>
<p>Soap1.1绑定</p>
</td>
</tr>
<tr>
<td>
<p><em>-2</em></p>
</td>
<td>
<p>SOAP1.2绑定</p>
</td>
</tr>
<tr>
<td>
<p><em>-C</em></p>
</td>
<td>
<p>只生成客户端代码</p>
</td>
</tr>
<tr>
<td>
<p><em>-S</em></p>
</td>
<td>
<p>只生成服务器端代码</p>
</td>
</tr>
<tr>
<td>
<p><em>-T</em></p>
</td>
<td>
<p>生成自动测试代码</p>
</td>
</tr>
<tr>
<td>
<p><em>-L</em></p>
</td>
<td>
<p>不生成 soapClientLib/soapServerLib</p>
</td>
</tr>
<tr>
<td>
<p><em>-a</em></p>
</td>
<td>
<p>用 SOAPAction 和WS-Addressing调用服务器端方法</p>
</td>
</tr>
<tr>
<td>
<p><em>-A</em></p>
</td>
<td>
<p>用 SOAPAction 调用服务器端方法</p>
</td>
</tr>
<tr>
<td>
<p><em>-b</em></p>
</td>
<td>
<p>采用<em>char[N]</em>这样的方式来表示string</p>
</td>
</tr>
<tr>
<td>
<p><em>-c</em></p>
</td>
<td>
<p>生成的是C代码，不是C++代码</p>
</td>
</tr>
<tr>
<td>
<p><em>-d &lt; path &gt;</em></p>
</td>
<td>
<p>将代码生成在&nbsp;<em>&lt; path &gt;下</em></p>
</td>
</tr>
<tr>
<td>
<p><em>-e</em></p>
</td>
<td>
<p>生成 SOAP RPC 样式的绑定</p>
</td>
</tr>
<tr>
<td>
<p><em>-f N</em></p>
</td>
<td>
<p>File split of N XML serializer implementations per file</p>
</td>
</tr>
<tr>
<td>
<p><em>-h</em></p>
</td>
<td>
<p>显示一个简要的用法信息</p>
</td>
</tr>
<tr>
<td>
<p><em>-i</em></p>
</td>
<td>
<p>生成的服务代理类和对象从struct soap继承而来</p>
</td>
</tr>
<tr>
<td>
<p><em>-j</em></p>
</td>
<td>
<p>生成的服务代理类和对象包含struct soap而来（C代码的唯一选择）</p>
</td>
</tr>
<tr>
<td>
<p><em>-I &lt; path &gt;</em></p>
</td>
<td>
<p>包含其他文件时使用，指明&nbsp;<em>&lt; path &gt;&nbsp;</em>(多个的话，用`:'分割)，相当于<em>#import</em>&nbsp;，该路径一般是gSOAP目录下的import目录，该目录下有一堆文件供soapcpp2生成代码时使用。</p>
</td>
</tr>
<tr>
<td>
<p><em>-n</em></p>
</td>
<td>
<p>用于生成支持多个客户端和服务器端（具体内容参考gSOAP文档）</p>
</td>
</tr>
<tr>
<td>
<p><em>-p &lt; name &gt;</em></p>
</td>
<td>
<p>生成的文件前缀采用<em>&lt; name &gt;&nbsp;</em>，而不是缺省的 "<em>soap</em>"</p>
</td>
</tr>
<tr>
<td>
<p><em>-q &lt; name &gt;</em></p>
</td>
<td>
<p>C++代码中，所有声明的命名空间</p>
</td>
</tr>
<tr>
<td>
<p><em>-s</em></p>
</td>
<td>
<p>生成的代码在反序列化时，严格检查XML的有效性</p>
</td>
</tr>
<tr>
<td>
<p><em>-t</em></p>
</td>
<td>
<p>生成的代码在发送消息时，采用xsi:type方式</p>
</td>
</tr>
<tr>
<td>
<p><em>-u</em></p>
</td>
<td>
<p>在 WSDL/schema 输出文件中不产生XML注释</p>
</td>
</tr>
<tr>
<td>
<p><em>-v</em></p>
</td>
<td>
<p>显示版本信息</p>
</td>
</tr>
<tr>
<td>
<p><em>-w</em></p>
</td>
<td>
<p>不生成 WSDL 和 schema 文件</p>
</td>
</tr>
<tr>
<td>
<p><em>-x</em></p>
</td>
<td>
<p>不生成 XML 形式的传输消息文件</p>
</td>
</tr>
<tr>
<td>
<p><em>-y</em></p>
</td>
<td>
<p>在XML 形式的传输消息文件中，包含 C/C++类型信息</p>
</td>
</tr>
</tbody>
</table></div>
<p><br><br></p>
<h2><a name="t4"></a><a name="_Toc453414529" target="_blank"></a><a name="t3" target="_blank"></a>2. wsdl2h的用法</h2>
<p>该工具是可以根据输入的wsdl或XSD或URL，产生相应的C/C++形式的.h（不能直接引用），供soapcpp2使用。</p>
<p>wsdl2h主要的运行选项如下：</p>
<p>&nbsp;</p>
<div class="table-wrapper"><table cellspacing="0" cellpadding="0" border="1">
<tbody>
<tr>
<td>
<p align="center"><strong>选项</strong></p>


</td>
<td>
<p align="center"><strong>描述</strong></p>


</td>


</tr>
<tr>
<td>
<p><em>-a</em></p>


</td>
<td>
<p>对匿名类型，产生基于顺序号的结构体名称</p>


</td>


</tr>
<tr>
<td>
<p><em>-c</em></p>


</td>
<td>
<p>生成C代码</p>


</td>


</tr>
<tr>
<td>
<p><em>-f</em></p>


</td>
<td>
<p>对schema扩展，产生flat C++类</p>


</td>


</tr>
<tr>
<td>
<p><em>-g</em></p>


</td>
<td>
<p>产生全局的元素声明</p>


</td>


</tr>
<tr>
<td>
<p><em>-h</em></p>


</td>
<td>
<p>显示帮助信息</p>


</td>


</tr>
<tr>
<td>
<p><em>-I path</em></p>


</td>
<td>
<p>包含文件时指明路径，相当于<em>#import</em></p>


</td>


</tr>
<tr>
<td>
<p><em>-j</em></p>


</td>
<td>
<p>不产生&nbsp;<em>SOAP_ENV__Header</em>&nbsp;和<em>SOAP_ENV__Detail</em>&nbsp;定义</p>


</td>


</tr>
<tr>
<td>
<p><em>-k</em></p>


</td>
<td>
<p>不产生&nbsp;<em>SOAP_ENV__Header mustUnderstand</em>&nbsp;qualifiers</p>


</td>


</tr>
<tr>
<td>
<p><em>-l</em></p>


</td>
<td>
<p>在输出中包含license信息</p>


</td>


</tr>
<tr>
<td>
<p><em>-m</em></p>


</td>
<td>
<p>用 xsd.h 
模块来引入类型信息</p>


</td>


</tr>
<tr>
<td>
<p><em>-N name</em></p>


</td>
<td>
<p>用<em>name</em>&nbsp;来指定服务命名空间的前缀。</p>


</td>


</tr>
<tr>
<td>
<p><em>-n name</em></p>


</td>
<td>
<p>用<em>name</em>&nbsp;作为命名空间的前缀，取代缺省的ns</p>


</td>


</tr>
<tr>
<td>
<p><em>-o file</em></p>


</td>
<td>
<p>输出文件名</p>


</td>


</tr>
<tr>
<td>
<p><em>-q name</em></p>


</td>
<td>
<p>所有的声明采用&nbsp;<em>name</em>&nbsp;作命名空间</p>


</td>


</tr>
<tr>
<td>
<p><em>-s</em></p>


</td>
<td>
<p>不产生 STL代码 (即不用 std::string，std::vector)</p>


</td>


</tr>
<tr>
<td>
<p><em>-t file</em></p>


</td>
<td>
<p>使用自己指定的type map file而不是缺省的typemap.dat</p>


</td>


</tr>
<tr>
<td>
<p><em>-u</em></p>


</td>
<td>
<p>不生成 unions</p>


</td>


</tr>
<tr>
<td>
<p><em>-v</em></p>


</td>
<td>
<p>产生详细的输出信息</p>


</td>


</tr>
<tr>
<td>
<p><em>-w</em></p>


</td>
<td>
<p>always wrap response parameters in a response struct</p>


</td>


</tr>
<tr>
<td>
<p><em>-y</em></p>


</td>
<td>
<p>为structs，enums产生 typedef定义</p>


</td>


</tr>
<tr>
<td>
<p><em>-_</em></p>


</td>
<td>
<p>不产生&nbsp;<em>_USCORE</em>&nbsp;(用UNICODE
 _x005f代替)</p>


</td>


</tr>
<tr>
<td>
<p><em>-?</em></p>


</td>
<td>
<p>显示帮助信息</p>


</td>


</tr>

</tbody>

</table></div>
<h1><a name="t5"></a><a name="_Toc453414530" target="_blank"></a>用gsoap开发web service的大致思路</h1>
<p>我们开发webservice应用，大致有两个方向：</p>
<p><strong>1.&nbsp; API接口固定，不关心底层的通讯，将SOAP作为应用层协议</strong></p>
<p>此时，我们先定义接口，编写好.h文件，运行soapcpp2生成出相应的代码，对服务器端，修改XXXService文件，实现业务逻辑，对客户端，修改XXXProxy文件，实现业务逻辑。</p>
<p><strong>2.&nbsp; 通讯协议固定（当然需要基于XML的）或只有wsdl，将SOAP作为“传输层”协议</strong></p>
<p>此时，我们必须根据通讯协议或wsdl生成相应的C/C++类型的.h文件，如果需要我们自己编写wsdl，则需要一点其相关知识，不过我们可以用C#等生成一个简单的wsdl，照猫画虎即可。运用wsdl2h，我们可以生成.h文件，有了.h后，按上面的步骤继续。</p>
<p>&nbsp;</p>
<p><a name="_Toc453414531" target="_blank"></a><strong>接口定义</strong></p>
<p>可参考《GSoap接口定义》。这里我将给出C#引用这个webserver所对应的接口形式。<br>
gsoap是根据我们定义好的.h文件，然后用工具产生了我们所需的.c文件。所以我们必须根据gsoap的要求编写.h。<br>
1. 单个参数的传出：<br>
int ns__add( int a, int b, int *c );<br>需要说明的是，这里的ns__是必须的，必须以开始注释中的ns加两个下划线开始。返回值必须是int。<br>但是这里的int并不是接口的返回值，而是gsoap内部的返回值。真正的返回值是int *c。<br><br>
C#中对应的接口: int add( int a, int b );返回值就是上述的int *c参数。<br><br>
2. 多个参数传出，在接口中必须使用结构体<br>
typedef char * xsd__string;<br>
typedef long xsd__int;<br>
struct ns__personResponse{<br>
xsd__int age;<br>
xsd__string name;<br>
xsd__string address;<br>
};<br>
int ns__person( xsd__string buf_in, struct ns__personResponse * buf_out );<br><br>在C#中，并不是我们所声明的这样。而是：int person( string buf_in, out string name, out string address);<br>即，结构体中的第一个域会变成返回值，其他的变成一个个的输出参数。<br><br>
3. 返回结构体。如果要返回结构图，那么必须在结构体中再套一层结构体：<br>
typedef char * xsd__string;<br>
typedef long xsd__int;<br>
struct ns__person{<br>
xsd__int age;<br>
xsd__string name;<br>
xsd__string address; <br>
};<br>
struct ns__personResponse{<br>
xsd__int ret;<br>
struct ns__person person;<br>
};<br>
int ns__person( xsd__string buf_in, struct ns__personResponse * buf_out );<br><br>那么在C#中，看到的接口是这样的：int person( string buf_in, person对应的结构类
 );<br><br>
4. 接口中的下划线，如果接口中的交易名有下划线，必须这么声明：<br>
int ns__echo_USCOREreverse( char * buf_in, char ** buf_out );<br><br>那么，C#中实际上的接口名就是：string echo_reverse( string buf_in );</p>
<p><a name="_Toc453414533" target="_blank"></a><strong>注意事项</strong></p>
<p><a name="_Toc453414534" target="_blank"></a><strong>gsoap</strong><strong>传输中文</strong>。</p>
<p>使用utf-8编码格式来支持汉字的传输。<br>
1. 设置gsoap为utf-8传输数据<br>
soap_set_mode( &amp;SmsWBS_soap, SOAP_C_UTFSTRING ); //设置编码<br>
SmsWBS_soap.mode|=SOAP_C_UTFSTRING;<br><br>
2. 使用下面得函数转换我们的传输内容，即将我们的数据转成UTF-8编码：<br>
int conv_charset( const char *dest, const char *src, char *input, size_t ilen,char *output, size_t olen )<br>
{<br>
int convlen = olen;<br>
iconv_t conv = iconv_open( dest, src );<br>
if( conv == (iconv_t) -1 )<br>
return -1;<br><br>
memset( output, 0, olen );<br>
if( iconv( conv, &amp;input, &amp;ilen, &amp;output, &amp;olen ) ){<br>
iconv_close(conv);<br>
return -1;<br>
}</p>
<p align="left">iconv_close(conv);<br>
return convlen-olen;<br>
}<br>例子： conv_charset( "UTF-8", "GBK", "林学任.linxr", strlen("林学任.linxr"),
 buf_out-&gt;name,100 );</p>
<p align="left">&nbsp;</p>
<p align="left">//编码转换函数
int&nbsp;code_convert(char&nbsp;*from_charset,char&nbsp;*to_charset,char&nbsp;*inbuf,int&nbsp;inlen,char&nbsp;*outbuf,int&nbsp;outlen)<br>{<br>iconv_t cd;<br>int&nbsp;rc;<br>char&nbsp;**pin&nbsp;=&nbsp;&amp;inbuf;<br>char&nbsp;**pout&nbsp;=&nbsp;&amp;outbuf;<br><br>cd&nbsp;=&nbsp;iconv_open(to_charset,from_charset);<br>if&nbsp;(cd==0)&nbsp;return&nbsp;-1;<br>memset(outbuf,0,outlen);<br>if&nbsp;(iconv(cd,pin,&amp;inlen,pout,&amp;outlen)==-1)&nbsp;return&nbsp;-1;<br>iconv_close(cd);<br>return&nbsp;0;<br>}<br>//UNICODE 2 GB2312<br>int&nbsp;u2g(char&nbsp;*inbuf,int&nbsp;inlen,char&nbsp;*outbuf,int&nbsp;outlen)<br>{<br>return&nbsp;code_convert("utf-8","gb2312",inbuf,inlen,outbuf,outlen);<br>}<br>//GB2312 2 UNICODE&nbsp;<br>int&nbsp;g2u(char&nbsp;*inbuf,size_t&nbsp;inlen,char&nbsp;*outbuf,size_t&nbsp;outlen)<br>{<br>return&nbsp;code_convert("gb2312","utf-8",inbuf,inlen,outbuf,outlen);<br>}</p>
<p align="left">&nbsp;</p>
<p align="left"><a name="_Toc453414535" target="_blank"></a><strong>内存管理</strong></p>
<p align="left">C/C++最大的麻烦，也是最大的优点是它要求用户自己管理内存。我们在实现web service方式时，同样需要考虑内存的分配与释放。</p>
<p align="left">分配内存有两类：</p>
<ul type="disc">
<li>分配n个字节，采用</li>

</ul>
<p align="left">void*soap_malloc(struct soap *soap, size_tn)&nbsp;</p>
<ul type="disc">
<li>分配某个类，采用</li>

</ul>
<p align="left">Class*soap_new_Class(struct soap*soap)&nbsp;&nbsp;&nbsp;一个类</p>
<p align="left">Class*soap_new_Class(struct soap *soap, intn)&nbsp;&nbsp;&nbsp; n个类</p>
<p align="left">这里的类是通讯xml中定义的元素，在response构造时，必然要创建若干此类元素。为简化类的创建，可定义如下宏：</p>
<div>
<p align="left">#defineNEW_ELEMENT(classtype)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soap_new_##classtype(GetSoapStruct(),-1)&nbsp;&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left">#defineNEW_ELEMENT_X(classtype,n)&nbsp;soap_new_##classtype(GetSoapStruct(),n)&nbsp;&nbsp;</p>


</div>
<p align="left">其中 GetSoapSturct()是返回继承的或包含的structsoap结构，对继承方式的代码，它的定义如下：</p>
<div>
<p align="left"><strong>struct</strong>&nbsp;soap&nbsp;*GetSoapStruct()&nbsp;{&nbsp;<strong>return</strong>(<strong>struct</strong>&nbsp;soap*)<strong>this</strong>;&nbsp;}&nbsp;&nbsp;</p>


</div>
<p align="left">在我们的Web方法实现中，可以随意使用上面的new方法，在每次web方法完结后，调用soap_destroy(structsoap
 *soap) ，它会为我们清除掉这部分内存。</p>
<p align="left">&nbsp;gsoap中有若干释放内存的方法，几个有用的函数（还有其它的，忽略）及其说明如下：</p>
<div class="table-wrapper"><table cellspacing="0" cellpadding="0" border="1">
<tbody>
<tr>
<td>
<p align="left"><span style="color: rgba(255, 0, 0, 1)"><strong>Function Call</strong></span></p>


</td>
<td>
<p align="left"><span style="color: rgba(255, 0, 0, 1)"><strong>Description</strong></span></p>


</td>


</tr>
<tr>
<td>
<p align="left"><em>soap_destroy(<strong>struct</strong>&nbsp;soap *soap)</em></p>


</td>
<td>
<p align="left">释放所有动态分配的C++类，必须在soap_end()之前调用。</p>


</td>


</tr>
<tr>
<td>
<p align="left"><em>soap_end(<strong>struct</strong>&nbsp;soap *soap)</em></p>


</td>
<td>
<p align="left">释放所有存储临时数据和反序列化数据中除类之外的空间（soap_malloc的数据也属于反序列化数据）。</p>


</td>


</tr>
<tr>
<td>
<p align="left"><em>soap_done(<strong>struct</strong>&nbsp;soap *soap)</em></p>


</td>
<td>
<p align="left">Detach soap结构（即初始化化soap结构）</p>


</td>


</tr>
<tr>
<td>
<p align="left"><em>soap_free(<strong>struct</strong>&nbsp;soap *soap)</em></p>


</td>
<td>
<p align="left">Detach 且释放soap结构</p>


</td>


</tr>

</tbody>

</table></div>
<p align="left">&nbsp;</p>
<p align="left"><span style="color: rgba(255, 0, 0, 1)">上表中，动态分配的C++类，指上
面用"soap_new"分配的类；临时数据是指那些在序列化/反序列化过程中创建的例如hash表等用来帮助解析、跟踪xml的数据；反序列化数据是指
在接收soap过程中产生的用malloc和new分配空间存储的数据。在gsoap中，纯数据空间与类空间管理不同，采用两个方法，可以保留soap的
反序列化数据（这时你需要自己释放）。</span></p>
<p align="left">&nbsp;</p>
<p align="left"><a name="_Toc453414536" target="_blank"></a><strong>gsoap</strong><strong>输出</strong></p>
<p align="left"><br>为提升服务性能,减少数据传输量,建议所有输出都采用字符方式的xml(UTF-8),不要采用结构或对象输出(输入可以),采用结构或对象输出优点是在客户端无需解析,自动生成相关对象和结构,但是会导致服务性能下降和传输的数量增大.例如:<br>int ns2__login(xsd__string username,xsd__stringpassword,xsd__string &amp;rsp);<br>rsp为字符串格式的xml,在客户端需要解析后方可使用.我自己定义的rsp有三种输出格式,所有节点名称都大写,所有属性名称都小写,节点之间无换行,客户端按下面的三种规则编写解析器即可.<br>第一种为服务器异常消息<br>&lt;DATA&gt;<br>&lt;ERROR val="服务器异常消息"/&gt;<br>&lt;/DATA&gt;<br><br><br>第二种为正常输入<br>&lt;DATA&gt;<br>&lt;ROWS&gt;<br>&lt;ROW v0="字段0的值"
 v1="字段1的值" vn="字段n的值"/&gt;<br>更多ROW.......................................&nbsp;<br>&lt;/ROWS&gt;<br>更多ROWS.......................................&nbsp;<br>&lt;/DATA&gt;<br><br><br>第三种为字段描述信息<br>&lt;DATA&gt;<br>&lt;FIELDS&gt;<br>&lt;FIELD &nbsp;name="字段名称" alias="字段描述信息"
 type=""size="" required=""/&gt;<br>更多字段描述信息.......................................<br>&lt;/ FIELDS &gt;<br>更多FIELDS.......................................<br>&lt;/DATA&gt;<br>type,size, required均为数字,type可以自己定义,解析时按自定义规则转换数据即可,size为字段大小,
 required值一般为0和1,为0表示不是必填,否则为必填项.<br>字符转换为保证可移值性,可采用iconv转换,windows和linux均支持,windows需要自己下载LibIconv
 for Windows -GnuWin32库.只需要记住UTF-8单个字符最多使用4字节存储即可.转换时一次性分配
 tcslen(szBuffer) * 4 + sizeof(TCHAR)大小的内存.</p>
<p align="left">&nbsp;</p>
<p><a name="_Toc453414537" target="_blank"></a><strong>webserver</strong><strong>发布</strong></p>
<p>1.&nbsp;&nbsp;&nbsp;&nbsp;在C#中，可以直接引用一个webserver，但是我们写得webserver如何能用被其引用呢。其实只要实现gsoap的fget回调函数即可：<br>
SmsWBS_soap.fget = http_get;<br>
2. http_get函数实现<br>
int http_get(struct soap * soap)<br>
{ <br>
FILE *fd = NULL;<br><br>
char *s = strchr( soap-&gt;path, '?' );<br>
if( !s || strcmp( s, "?wsdl" ) ){<br>
return SOAP_GET_METHOD;<br>
}<br><br>
fd = fopen( "SmsWBS.wsdl", "rb" );<br>
if (!fd){<br>
return 404;<br>
}<br><br>
soap-&gt;http_content = "text/xml";<br>
soap_response(soap, SOAP_FILE);<br>
for (;;){ <br>
size_t r = fread(soap-&gt;tmpbuf, 1, sizeof(soap-&gt;tmpbuf), fd);<br>
if( !r ){<br>
break;<br>
}<br>
if( soap_send_raw( soap, soap-&gt;tmpbuf, r) ){<br>
break; <br>
}<br>
}<br><br>
fclose(fd);<br>
soap_end_send(soap);<br><br>
return SOAP_OK;<br>
}</p>
<p>&nbsp;这个具体参见文章：https://www.cnblogs.com/liushui-sky/p/9723385.html</p>
<p>&nbsp;</p>
<p align="left"><a name="_Toc453414538" target="_blank"></a>CGI方式执行</p>
<p align="left">server端可以编译成CGI方式执行，而并不是绑定到某个端口，这种方式我没有实践。</p>
<p align="left">if (argc &lt; 2)// <span style="color: rgba(255, 0, 0, 1)">no args: assume this is a CGIapplication</span><br>{ <br>
soap_serve(&amp;soap); // serve request, one thread, CGI style <br>
soap_destroy(&amp;soap); // dealloc C++ data <br>
soap_end(&amp;soap); // dealloc data and clean up <br>
}</p>
<p>&nbsp;<a href="http://blog.csdn.net/ygm_linux/article/details/44650733" rel="nofollow" target="_blank">gsoap上层缓冲区大小设置</a></p>
<p>通过更改在stdsoap2.h文件中 SOAP_BUFLEN 宏，增加缓存大小，默认缓存大小为65536</p>
<p><a name="_Toc453414539" target="_blank"></a>实现高性能gsoap服务</p>
<p><img src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/20160615114108135.jpg" alt=""></p>
<p>代码请参看gSOAP 2.8.14 User Guide中的7.2.4 &nbsp;How to Create
 aMulti-Threaded Stand-Alone Service.<br>&nbsp; &nbsp; listen : 监听soap_accept方法,返回一个SOAP_SOCKET,然后交SOAP_SOCKET添加到队列,并发送一个信号通知process(处理线程)处理.&nbsp;<br>process(处理线程)启动后立即阻塞等待信号,收到信号后才执行相应的任务(soap_serve<br>),执行任务后继续阻塞等待信号.<strong><span style="color: rgba(255, 0, 0, 1)">注
意:soap_serve方法如果客户端提交的xml文档格式不正确或其它数据(恶意攻击)时会一直阻塞到下一个请求,导致服务器性能严重下降,客户端无
法收到数据一直等待的情况,因此在初始化处理线程的soap成功后,应该立即设置处理线程soap的超时时间,单位为秒:</span></strong><br>
<span style="color: rgba(255, 0, 0, 1)">soap_thr[i] = soap_copy(&amp;soap);//在这一行示例代码后一加下面三行代码</span><br><span style="color: rgba(255, 0, 0, 1)">
soap_thr[i] -&gt;send_timeout = 1;</span><br><span style="color: rgba(255, 0, 0, 1)">
soap_thr[i] -&gt;recv_timeout = 1;</span><br><span style="color: rgba(255, 0, 0, 1)">
soap_set_mode(soap_thr[i], SOAP_C_UTFSTRING); /*设置采用UTF-8字符编码*/</span></p>
<p><a name="_Toc453414540" target="_blank"></a>gSOAP写服务器端程序</p>
<p><a href="http://blog.csdn.net/mseaspring/article/details/1713283" rel="nofollow" target="_blank">http://blog.csdn.net/mseaspring/article/details/1713283</a></p>
<p>gSOAP写服务器端程序，现在将gSOAP文档中的算术服务器的程序与文档中的多线程服务器结合，写了个多线程算术服务器。&nbsp;</p>
<p>一 gSOAP需要的头文件：</p>
<p>//gsoap ns servicename:&nbsp;calc<br>
//gsoap ns service style:&nbsp;rpc<br>
//gsoap ns service encoding:&nbsp;encoded<br>
//gsoap ns service namespace:&nbsp;<a href="http://127.0.0.1:8089/calc.wsdl" rel="nofollow" target="_blank">http://127.0.0.1:8089/calc.wsdl</a><br>//gsoapns service location:&nbsp;<a href="http://127.0.0.1:8089/cal" rel="nofollow" target="_blank">http://127.0.0.1:8089/cal</a><br>//gsoapns schema&nbsp; namespace:&nbsp;&nbsp;&nbsp; urn:calc<br>
int ns__add(double a, double b, double *result);<br>
int ns__sub(double a, double b, double *result);<br>
int ns__mul(double a, double b, double *result);<br>
int ns__div(double a, double b, double *result);<br>
int ns__pow(double a, double b, double *result);</p>
<p>二多线程服务器关键代码</p>
<p>#include&nbsp;&nbsp;<br>
#include&nbsp; "calc.nsmap"<br>
#include&nbsp; "soapH.h"</p>
<p>/////////////////////////////////////////////////////////////////////////<br>
///宏与全局变量的定义<br>
#define&nbsp; BACKLOG (100)&nbsp;&nbsp;<br>
#define&nbsp; MAX_THR (10)&nbsp;&nbsp;&nbsp;<br>
#define&nbsp; MAX_QUEUE (1000)</p>
<p><br>pthread_mutex_tqueue_cs;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//
队列锁<br>
pthread_cond_t&nbsp;queue_cv;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//
条件变量<br>
SOAP_SOCKET&nbsp;&nbsp;&nbsp;&nbsp; queue[MAX_QUEUE];&nbsp;&nbsp; //数组队列<br>
int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;head
 =0, tail 
=0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//队列头队列尾初始化&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
//////////////////////////////////////////////////////////////////////////</p>
<p><br>//////////////////////////////////////////////////////////////////////////<br>
void *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; process_queue(void*);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //线程入口函数<br>
int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enqueue(SOAP_SOCKET);&nbsp;//入队列函数<br>
SOAP_SOCKET dequeue(void);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //出队列函数</p>
<p>//////////////////////////////////////////////////////////////////////////<br>
//线程入口函数<br>
void * process_queue(void * soap)<br>
{<br>
&nbsp; struct soap * tsoap = (struct soap *)soap;<br>
&nbsp; for(;;)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tsoap-&gt;socket = dequeue();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(!soap_valid_socket(tsoap-&gt;socket))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soap_serve(tsoap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soap_destroy(tsoap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soap_end(tsoap);<br>
&nbsp; }<br>
&nbsp; return NULL;<br>
}</p>
<p>//入队列操作<br>
int enqueue(SOAP_SOCKET sock)<br>
{<br>
&nbsp; int status = SOAP_OK;<br>
&nbsp; int next;<br>
&nbsp; pthread_mutex_lock(&amp;queue_cs);<br>
&nbsp; next = tail +1;<br>
&nbsp; if (next &gt;= MAX_QUEUE)&nbsp;<br>
&nbsp;&nbsp;&nbsp; next = 0;<br>
&nbsp; if (next == head)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; status = SOAP_EOM;<br>
&nbsp; else<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; queue[tail] =sock;<br>
&nbsp;&nbsp;&nbsp; tail = next;<br>
&nbsp; }<br>
&nbsp; pthread_cond_signal(&amp;queue_cv);<br>
&nbsp; pthread_mutex_unlock(&amp;queue_cs);<br>
&nbsp; return status;<br>
}</p>
<p>//出队列操作<br>
SOAP_SOCKET dequeue()<br>
{<br>
&nbsp; SOAP_SOCKET sock;<br>
&nbsp; pthread_mutex_lock(&amp;queue_cs);<br>
&nbsp;&nbsp; while (head == tail )<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_cond_wait(&amp;queue_cv,&amp;queue_cs);<br>
&nbsp;&nbsp; }<br>
&nbsp; sock = queue[head++];<br>
&nbsp; if (head &gt;= MAX_QUEUE)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; head =0;<br>
&nbsp; }<br>
&nbsp; pthread_mutex_unlock(&amp;queue_cs);<br>
&nbsp; return sock;<br>
}</p>
<p><br>//////////////////////////具体服务方法////////////////////////////////////////<br>
//加法的实现<br>
int ns__add(struct soap *soap, double a, double b, double *result)<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *result = a + b;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return SOAP_OK;<br>
}&nbsp;<br>
//减法的实现<br>
int ns__sub(struct soap *soap, double a, double b, double *result)<br>
{&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp; *result = a - b;<br>
&nbsp;&nbsp;&nbsp;&nbsp; return SOAP_OK;<br>
}&nbsp;<br>
//乘法的实现<br>
int ns__mul(struct soap *soap, double a, double b, double *result)<br>
{&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp; *result = a * b;<br>
&nbsp;&nbsp;&nbsp;&nbsp; return SOAP_OK;<br>
}&nbsp;<br>
//除法的实现<br>
int ns__div(struct soap *soap, double a, double b, double *result)<br>
{&nbsp;<br>
&nbsp;&nbsp; if (b)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *result = a / b;<br>
&nbsp;&nbsp; else<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *s = (char*)soap_malloc(soap,1024);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
sprintf(s,"Can't"&gt;http://tempuri.org/"&gt;Can't&nbsp;divide %f by 
%f", a, b);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return soap_sender_fault(soap,"Division by zero", s);<br>
&nbsp; }<br>
&nbsp; return SOAP_OK;<br>
}&nbsp;<br>
//乘方的实现<br>
int ns__pow(struct soap *soap, double a, double b, double *result)<br>
{&nbsp;<br>
&nbsp; *result = pow(a, b);<br>
&nbsp; if (soap_errno == EDOM) /* soap_errno 和errorno类似,但是和widnows兼容
 */<br>
&nbsp; {&nbsp;<br>
&nbsp;&nbsp;&nbsp; char *s = (char*)soap_malloc(soap, 1024);<br>
&nbsp;&nbsp;&nbsp; sprintf(s, "Can't take the power of %f to&nbsp;%f", a, b);<br>
&nbsp;&nbsp;&nbsp; sprintf(s,"Can't"&gt;http://tempuri.org/"&gt;Can't&nbsp;take power of %f to %f", a, b);<br>
&nbsp;&nbsp;&nbsp; return soap_sender_fault(soap, "Power function domainerror", s);<br>
&nbsp; }<br>
&nbsp; return SOAP_OK;<br>
}</p>
<p>//////////////////////////////////////////////////////////////////////////////////////////////////////<br>
//主函数<br>
int main(int argc,char ** argv)<br>
{<br>
&nbsp; struct soap ServerSoap;<br>
&nbsp;&nbsp;&nbsp;&nbsp; //初始话运行时环境<br>
&nbsp;&nbsp;&nbsp; soap_init(&amp;ServerSoap);<br>
&nbsp;&nbsp;&nbsp; //如果没有参数，当作CGI程序处理<br>
&nbsp;&nbsp;&nbsp; if (argc &lt;2)&nbsp;<br>
&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //CGI 风格服务请求，单线程<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soap_serve(&amp;ServerSoap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //清除序列化的类的实例<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soap_destroy(&amp;ServerSoap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //清除序列化的数据<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soap_end(&amp;ServerSoap);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp; }else<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp; struct soap * soap_thr[MAX_THR];<br>
&nbsp;&nbsp;&nbsp;&nbsp; pthread_t tid[MAX_THR];<br>
&nbsp;&nbsp;&nbsp;&nbsp; int i,port = atoi(argv[1]);<br>
&nbsp;&nbsp;&nbsp;&nbsp; SOAP_SOCKET m,s;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //锁和条件变量初始化<br>
&nbsp;&nbsp;&nbsp;&nbsp; pthread_mutex_init(&amp;queue_cs,NULL);<br>
&nbsp;&nbsp;&nbsp;&nbsp; pthread_cond_init(&amp;queue_cv,NULL);<br>
&nbsp;&nbsp;&nbsp;&nbsp; //绑定服务端口<br>
&nbsp;&nbsp;&nbsp; m = soap_bind(&amp;ServerSoap,NULL,port,BACKLOG);<br>
&nbsp;&nbsp;&nbsp; //循环直至服务套接字合法<br>
&nbsp;&nbsp;&nbsp; while (!soap_valid_socket(m))<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,"Bind port error! ");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m
 = soap_bind(&amp;ServerSoap,NULL,port,BACKLOG);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; fprintf(stderr,"socket connection successful %d",m);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp; //生成服务线程<br>
&nbsp;&nbsp;&nbsp;&nbsp;for(i = 0; i &lt;MAX_THR; i++)</p>
<p>&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soap_thr[i] = soap_copy(&amp;ServerSoap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr,"Starting thread %d",i);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_create(&amp;tid[i],NULL,(void*(*)(void*))process_queue,(void*)soap_thr[i]);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp; for(;;)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //接受客户端的连接<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = soap_accept(&amp;ServerSoap);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!soap_valid_socket(s))&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ServerSoap.errnum)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;soap_print_fault(&amp;ServerSoap,stderr);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,"Server timed out ");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //客户端的IP地址<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr,"Accepted connection fromIP= %d.%d.%d.%d socket = %d ",<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((ServerSoap.ip)&gt;&gt;24)&amp;&amp;0xFF,((ServerSoap.ip)&gt;&gt;16)&amp;0xFF,((ServerSoap.ip)&gt;&gt;8)&amp;0xFF,(ServerSoap.ip)&amp;0xFF,(ServerSoap.socket));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //请求的套接字进入队列，如果队列已满则循环等待<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while(enqueue(s) == SOAP_EOM)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sleep(1000);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; //服务结束后的清理工作<br>
&nbsp;&nbsp;&nbsp; for(i = 0; i &lt; MAX_THR; i++)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (enqueue(SOAP_INVALID_SOCKET) ==SOAP_EOM)&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Sleep(1000);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; for(i=0; i&lt; MAX_THR; i++)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr,"Waiting for thread %d toterminate ..",i);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_join(tid[i],NULL);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr,"terminated ");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; soap_done(soap_thr[i]);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; free(soap_thr[i]);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; pthread_mutex_destroy(&amp;queue_cs);<br>
&nbsp;&nbsp;&nbsp; pthread_cond_destroy(&amp;queue_cv);<br>
&nbsp; }<br>
&nbsp;&nbsp;&nbsp; //分离运行时的环境<br>
&nbsp; soap_done(&amp;ServerSoap);<br>
&nbsp; return 0;<br>
}</p>
<p>&nbsp;</p>
<p><a href="http://blog.csdn.net/qianchenglenger/article/details/16907821" rel="nofollow" target="_blank">在windows下配置pthread</a><a name="_Toc453414541" target="_blank"></a></p>
<p>Pthread是由POSIX提出的一套通用的线程库，在linux平台下，它被广泛的支持，而windows平台下，却并不被支持，而
pthreads-w32为我们提供了解决方案，本文我们准备在我们的windows平台下进行pthread-w32的安装，在网络上有类似的文章，但
是讲的都是比较老的平台，在windows8下支持并不全面，不过可以作为参考。我们在这里贴出几个网址，供参考使用。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://blog.csdn.net/npuweiwei/article/details/8666373" rel="nofollow" target="_blank">Windows 7 64bit和</a>Visual
 Studio 2010下安装及使用Pthread-w32 2.8&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.cppblog.com/liquidx/archive/2009/06/16/87811.html" rel="nofollow" target="_blank">windows下使用</a>pthread库(转)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果你的是XP系统或者win7 32位系统，那么，那两篇文章已经足以你完成pthread-w32的安装了。现在，我们开始讲我们的尝试过程。</p>
<h3><a name="t6"></a><a name="_Toc453414542" target="_blank"></a><a name="t0" target="_blank"></a>一、安装平台</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;windows8 64位系统，MicrosoftVisual Studio 2012</p>
<h3><a name="t7"></a><a name="_Toc453414543" target="_blank"></a>二、pthreads-w32下载地址</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我们这里下载最新版本pthreads-w32-2-9-1</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a rel="nofollow" target="_blank">ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip</a></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;下载后解压，可以看到共有三个文件夹</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我们用到的主要是“Pre-built.2”这个文件夹下的三个文件夹，分别是动态链接库、头文件、静态链接库</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<h3><a name="t8"></a><a name="_Toc453414544" target="_blank"></a>三、配置头文件及静态链接库</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;这里有多种方式，我们这里只提到我们用到的一种，总之目的是让我们建立的工程能够找到对应的头文件、静态库文件，以及运行时程序能够找到动态链接库文件。</p>
<p>这里，我们直接把头文件拷贝到Visual Studio的默认路径的头文件中，即把include文件夹中的三个文件直接拷贝到VisualStudio安装目录下VC-&gt;include文件夹下，例如我将include中文件拷贝到的位置是</p>
<p>E:\ProgramFiles\Microsoft Visual Studio 11.0\VC\include</p>
<p>这样，我们就不必每次在项目用到时都配置一遍，特别是在Visual Studio2012貌似不支持全局的头文件配置时（不确定，如果谁找到了可以告诉我一声），这种方式对于经常会建一些小项目的人来说，相对节省时间。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;同样的办法与原因，我们也可以把lib文件夹下的内容拷贝
到Visual Studio安装目录下默认的lib寻找路径中，即VC-&gt;lib中，例如我将lib文件夹下的x64与x86两个文件直接拷贝到</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;E:\Program Files\Microsoft Visual Studio 11.0\VC\lib</p>
<p>的下面。</p>
<h3><a name="t9"></a><a name="_Toc453414545" target="_blank"></a>四、配置动态链接库</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;和头文件和静态链接库的配置方式相似，我们这里将dll文件夹的内容放到我们程序能够找到的位置，我们的方案是</p>
<p>把dll下的x64文件夹下的两个文件，即pthreadGC2.dll与pthreadVC2.dll拷贝到C:\Windows\System32下（用于64位程序的运行）</p>
<p>把dll下的x86文件夹下的五个文件，拷贝到C:\Windows\SysWOW64下（用于32位程序的运行），注意一下，千万不能将这些文件拷贝反位置，否则，程序运行时会提示说找不到对应的dll文件。这些在网上的很多文章中都被忽略掉了，所以我们特别提出。</p>
<h3><a name="t10"></a><a name="_Toc453414546" target="_blank"></a><a name="t4" target="_blank"></a>五、运行测试</h3>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;完成以上配置之后，我们运行一下测试程序，证明我们的配置完成了</p>
<p>//main.cpp</p>
<p>#include &lt;stdio.h&gt;</p>
<p>#include &lt;pthread.h&gt;</p>
<p>#include &lt;assert.h&gt;</p>
<p>&nbsp;</p>
<p>#pragmacomment(lib,"x86/pthreadVC2.lib")</p>
<p>&nbsp;</p>
<p>void* Function_t(void* Param)</p>
<p>{</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("我是线程！ ");</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_tmyid = pthread_self();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("线程ID=%d ", myid);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnNULL;</p>
<p>}</p>
<p>&nbsp;</p>
<p>int main()</p>
<p>{</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_tpid;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_attr_tattr;</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_attr_init(&amp;attr);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_attr_setscope(&amp;attr,PTHREAD_SCOPE_PROCESS);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_attr_setdetachstate(&amp;attr,PTHREAD_CREATE_DETACHED);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_create(&amp;pid,&amp;attr, Function_t, NULL);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("========================================");</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getchar();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pthread_attr_destroy(&amp;attr);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return0;</p>
<p>}</p>
<p>&nbsp;</p>
<p>这里，我们需要注意的是我们的第6行代码，我们需要在代码中包含入静态链接库（注意，根据不同的编译选项，选择x86还是x64，如果不相配，将无法链接完成）</p>
<p>#pragmacomment(lib,"x86/pthreadVC2.lib")</p>
<p>&nbsp;</p>
<p>&nbsp;gsoap实例代码下载：<a href="http://download.csdn.net/detail/byxdaz/9549883" rel="nofollow" target="_blank">http://download.csdn.net/detail/byxdaz/9549883</a></p>
<p><a name="_Toc453414547" target="_blank"></a>参考资料：</p>
<p>官网源代码： <a href="https://sourceforge.net/projects/gsoap2/" rel="nofollow" target="_blank">
https://sourceforge.net/projects/gsoap2/</a></p>
<p>帮助文档：<span xml:lang="en-us" lang="en-us"><a href="http://www.cs.fsu.edu/~engelen/soapdoc2.html" rel="nofollow" target="_blank">http://www.cs.fsu.edu/~engelen/soapdoc2.html</a></span></p>
<p>gsoap使用总结：<a href="http://www.cnblogs.com/linxr/archive/2011/10/17/2215285.html" rel="nofollow" target="_blank">http://www.cnblogs.com/linxr/archive/2011/10/17/2215285.html</a></p>
<p>C#访问gsoap的服务：<a href="http://blog.csdn.net/caowei880123/article/details/49129211" rel="nofollow" target="_blank">http://blog.csdn.net/caowei880123/article/details/49129211#</a></p>
<p>windows下使用pthread库:<a href="http://blog.csdn.net/g_spider/article/details/6023698#comments" rel="nofollow" target="_blank">http://blog.csdn.net/g_spider/article/details/6023698#comments</a></p>
<p>转自：https://blog.csdn.net/byxdaz/article/details/51679117</p>
</div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="EntryTag">
    标签: 
            <a href="https://www.cnblogs.com/liushui-sky/tag/gsoap/">gsoap</a>,             <a href="https://www.cnblogs.com/liushui-sky/tag/webservice/">webservice</a>,             <a href="https://www.cnblogs.com/liushui-sky/tag/good/">good</a></div>

    <div id="blog_post_info">
<div id="green_channel">
        <a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(9723397,cb_blogId,1);green_channel_success(this,'谢谢推荐！');">好文要顶</a>
        <a id="green_channel_follow" onclick="follow('a9424756-340f-e111-b422-842b2b196315');" href="javascript:void(0);">关注我</a>
    <a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a>
    <a id="green_channel_weibo" href="javascript:void(0);" title="分享至新浪微博" onclick="ShareToTsina()"><img src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/icon_weibo_24.png" alt=""></a>
    <a id="green_channel_wechat" href="javascript:void(0);" title="分享至微信" onclick="shareOnWechat()"><img src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/wechat.png" alt=""></a>
</div>
<div id="author_profile">
    <div id="author_profile_info" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/liushui-sky/" target="_blank"><img src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/20200525152532.png" class="author_avatar" alt=""></a>
        <div id="author_profile_detail" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/liushui-sky/">苦涩的茶</a><br>
            <a href="https://home.cnblogs.com/u/liushui-sky/followees/">关注 - 18</a><br>
            <a href="https://home.cnblogs.com/u/liushui-sky/followers/">粉丝 - 102</a>
        </div>
    </div>
    <div class="clear"></div>
    <div id="author_profile_honor"></div>
    <div id="author_profile_follow">
                <a href="javascript:void(0);" onclick="follow('a9424756-340f-e111-b422-842b2b196315');return false;">+加关注</a>
    </div>
</div>
<div id="div_digg">
    <div class="diggit" onclick="votePost(9723397,'Digg')">
        <span class="diggnum" id="digg_count">1</span>
    </div>
    <div class="buryit" onclick="votePost(9723397,'Bury')">
        <span class="burynum" id="bury_count">0</span>
    </div>
    <div class="clear"></div>
    <div class="diggword" id="digg_tips">
    </div>
</div>

<script type="text/javascript">
    currentDiggType = 0;
</script></div>
    <div class="clear"></div>
    <div id="post_next_prev">

    <a href="https://www.cnblogs.com/liushui-sky/p/9723385.html" class="p_n_p_prefix">« </a> 上一篇：    <a href="https://www.cnblogs.com/liushui-sky/p/9723385.html" title="发布于 2018-09-29 14:03">Linux下用gSOAP开发Web Service服务端和客户端程序</a>
    <br>
    <a href="https://www.cnblogs.com/liushui-sky/p/9726603.html" class="p_n_p_prefix">» </a> 下一篇：    <a href="https://www.cnblogs.com/liushui-sky/p/9726603.html" title="发布于 2018-09-29 20:45">WireShark如何抓取本地localhost的包</a>

</div>
</div>
	<div class="postDesc">posted on 
<span id="post-date">2018-09-29 14:07</span>&nbsp;
<a href="https://www.cnblogs.com/liushui-sky/">苦涩的茶</a>&nbsp;
阅读(<span id="post_view_count">9614</span>)&nbsp;
评论(<span id="post_comment_count">0</span>)&nbsp;
<a href="https://i.cnblogs.com/EditPosts.aspx?postid=9723397" rel="nofollow">编辑</a>&nbsp;
<a href="javascript:void(0)" onclick="AddToWz(9723397);return false;">收藏</a>&nbsp;
<a href="javascript:void(0)" onclick="reportManager.report({ currentUserId: '', targetType: 'blogPost', targetId: '9723397', targetLink: 'https://www.cnblogs.com/liushui-sky/p/9723397.html', title: 'gsoap使用总结' })">举报</a></div>
</div>



<script src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/highlight.js" async="" onload="markdown_highlight()"></script>
<script>
    var allowComments = true, cb_blogId = 101800, cb_blogApp = 'liushui-sky', cb_blogUserGuid = 'a9424756-340f-e111-b422-842b2b196315';
    var cb_entryId = 9723397, cb_entryCreatedDate = '2018-09-29 14:07', cb_postType = 1;
    updatePostStats(
        [cb_entryId],
        function(id, count) { $("#post_view_count").text(count) },
        function(id, count) { $("#post_comment_count").text(count) })
    zoomManager.apply("#cnblogs_post_body img:not(.code_img_closed):not(.code_img_opened)");
</script>

<a name="!comments"></a>
<div id="blog-comments-placeholder"></div>
<div id="comment_form" class="commentform">
    <a name="commentform"></a>
    <div id="divCommentShow"></div>
    <div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" onclick="return RefreshCommentList();" id="lnk_RefreshComments" runat="server" clientidmode="Static">刷新评论</a><a href="#" onclick="return RefreshPage();">刷新页面</a><a href="#top">返回顶部</a></div>
    <div id="comment_form_container" style="visibility: visible;"><div class="login_tips">
    登录后才能查看或发表评论，立即 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return account.login('!comments');">登录</a> 或者
    <a href="https://www.cnblogs.com/">逛逛</a> 博客园首页
</div>
</div>
    <div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
    <div id="ad_t2"><a href="https://cloud.baidu.com/campaign/2021autdiscount/index.html?track=cp:bokeyuan|pf:pc|pp:bokeyuan-huodong-21puhuishangyun-neiyewenzilian|pu:21puhuishangyun-neiyewenzilian|ci:21phsy|kw:10305382" target="_blank" onclick="ga('send', 'event', 'Link', 'click', 'T2-百度云-普惠上云节')">【推荐】百度智能云2021普惠上云节：新用户首购云服务器低至0.7折</a><br><a href="https://www.aliyun.com/minisite/goods?taskCode=yds2021-07zy&amp;recordId=807539&amp;userCode=swh7dvlt" target="_blank" onclick="ga('send', 'event', 'Link', 'click', 'T2-阿里云-cps')">【推荐】阿里云云大使特惠：新用户购ECS服务器1核2G最低价87元/年</a><br><a href="http://www.uccpsoft.com/index.htm" target="_blank" onclick="ga('send', 'event', 'Link', 'click', 'T2-ucancode')">【推荐】大型组态、工控、仿真、CAD\GIS 50万行VC++源码免费下载!</a><br><a href="https://brands.cnblogs.com/huawei" target="_blank" onclick="ga('send', 'event', 'Link', 'click', 'T2-华为专区')">【推荐】和开发者在一起：华为开发者社区，入驻博客园科技品牌专区</a><br><a href="https://www.cnblogs.com/cmt/p/15147135.html" target="_blank" onclick="ga('send', 'event', 'Link', 'click', 'T2-众安保险')">【推广】园子与爱卡汽车爱宝险合作，随手就可以买一份的百万医疗保险</a><br></div>
    <div id="opt_under_post"></div>
    <div id="cnblogs_c1" class="under-post-card">
             <a onclick="ga('send', 'event', 'Link', 'click', 'Pangle-C1')" target="_blank" rel="nofollow" href="https://c.gridsumdissector.com/r/?gid=gad_545_ph4hkwzt&amp;ck=32&amp;adk=442&amp;autorefresh=__AUTOREFRESH__">
                <img style="width: 300px; height: 250px;" src="gsoap%E4%BD%BF%E7%94%A8%E6%80%BB%E7%BB%93%20-%20%E8%8B%A6%E6%B6%A9%E7%9A%84%E8%8C%B6%20-%20%E5%8D%9A%E5%AE%A2%E5%9B%AD_files/35695-20210817131346802-930113090.jpg" alt="" onload="gscmdImpress()">
             </a>
    </div>
    <div id="under_post_card1"><div class="under-post-card">
<b>编辑推荐：</b>
<br>

· <a href="https://www.cnblogs.com/duck-coding/p/15190943.html" target="_blank">熟悉而陌生的新朋友——IAsyncDisposable</a>
    <br>
· <a href="https://www.cnblogs.com/artech/p/object-pool-03.html" target="_blank">对象池在 .NET (Core)中的应用[3]: 扩展篇</a>
    <br>
· <a href="https://www.cnblogs.com/coco1s/p/15178959.html" target="_blank">奇思妙想 CSS 3D 动画 | 仅使用 CSS 能制作出多惊艳的动画？</a>
    <br>
· <a href="https://www.cnblogs.com/imyalost/p/15184433.html" target="_blank">一个测试工程师的成长复盘</a>
    <br>
· <a href="https://www.cnblogs.com/daxnet/p/15177443.html" target="_blank">何时使用领域驱动设计</a>
    <br>
</div></div>
    <div id="under_post_card2"><div class="itnews under-post-card">
    <b>最新新闻</b>：
    <br>
 ·          <a href="https://news.cnblogs.com/n/701231/" target="_blank">苹果再度向开发者妥协：即将开放第三方支付，30%“苹果税”松动（2021-08-30 16:00）</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/701230/" target="_blank">谷歌学术公布2021年最有影响力工作，CV顶会论文“夹缝求生”（2021-08-30 15:50）</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/701229/" target="_blank">何小鹏和俞永福的背水一战（2021-08-30 15:36）</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/701228/" target="_blank">快手站在新的十字路口（2021-08-30 15:23）</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/701227/" target="_blank">接下来，拼多多会把钱花到哪？（2021-08-30 15:10）</a>
        <br>
    » <a href="https://news.cnblogs.com/" title="IT 新闻" target="_blank">更多新闻...</a>
</div></div>
    <div id="HistoryToday" class="under-post-card">
<b>历史上的今天：</b>
<br>

2016-09-29    <a href="https://www.cnblogs.com/liushui-sky/p/5920065.html">C++ 的一个问题的理解（私有变量成员）</a>
    <br>
2016-09-29    <a href="https://www.cnblogs.com/liushui-sky/p/5920050.html">C++复制构造函数和赋值符的区别</a>
    <br>
</div>
    <script type="text/javascript">
       var commentManager = new blogCommentManager();
       commentManager.renderComments(0);
       fixPostBody();
       deliverBigBanner();
setTimeout(function() { incrementViewCount(cb_entryId); }, 50);       deliverT2();
       deliverC1C2();
       loadNewsAndKb();
LoadPostCategoriesTags(cb_blogId, cb_entryId);       LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
       GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType);
       loadOptUnderPost();
       GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);
    </script>
</div>

</div>


</div>
<div id="leftcontent">
	
		<div id="leftcontentcontainer">
			
<div id="sidebar_c3"></div>
			<div id="calendar"><div id="blog-calendar" style="display:none"></div></div>                
                    <script>loadBlogDefaultCalendar();</script><br>
			<div id="blog-sidecolumn"><!-- 搜索 -->
<div id="sidebar_search" class="sidebar-block">
    <div id="sidebar_search" class="mySearch">
        <h3 class="catListTitle">搜索</h3>
        <div id="sidebar_search_box">
            <div id="widget_my_zzk" class="div_my_zzk">
                <input type="text" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk">&nbsp;<input onclick="zzk_go()" type="button" value="找找看" id="btnZzk" class="btn_my_zzk">
            </div>
            <div id="widget_my_google" class="div_my_zzk">
                <input type="text" name="google_q" id="google_q" onkeydown="return google_go_enter(event);" class="input_my_zzk">&nbsp;<input onclick="google_go()" type="button" value="谷歌搜索" class="btn_my_zzk">
            </div>
        </div>
    </div>
</div>

<!-- 常用链接 -->


<!-- 最新随笔 -->


<!-- 我的标签 -->
<div id="sidebar_toptags" class="sidebar-block">
<h3>我的标签</h3>
<div id="MyTag">
    <ul>
                <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/good/">good<span class="tag-count">(102)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/Qt%E5%AD%A6%E4%B9%A0%E4%B9%8B%E8%B7%AF/">Qt学习之路<span class="tag-count">(69)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/c%2B%2B/">c++<span class="tag-count">(55)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/linux%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E4%BD%BF%E7%94%A8/">linux操作系统使用<span class="tag-count">(26)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/c/">c<span class="tag-count">(24)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/gsoap/">gsoap<span class="tag-count">(21)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/Qt%E4%BD%BF%E7%94%A8%E9%97%AE%E9%A2%98/">Qt使用问题<span class="tag-count">(20)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/Qt%E7%B1%BB/">Qt类<span class="tag-count">(20)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/Qt---tcp/">Qt---tcp<span class="tag-count">(19)</span></a>
        </li>
        <li>
            <a href="https://www.cnblogs.com/liushui-sky/tag/webservice/">webservice<span class="tag-count">(18)</span></a>
        </li>
    <li>
        <a href="https://www.cnblogs.com/liushui-sky/tag/">更多</a>
    </li>

    </ul>
</div>
</div>

<!-- 积分与排名 -->


<!-- 随笔分类、随笔档案、文章分类、新闻分类、相册、链接 -->
<div id="sidebar_categories">

    <h3 class="catListTitle">
        
随笔档案



    </h3>
    <ul class="catList">
            <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2021/08.html" rel="" target="">
    2021年8月(3)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2021/06.html" rel="" target="">
    2021年6月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2021/03.html" rel="" target="">
    2021年3月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2021/02.html" rel="" target="">
    2021年2月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2021/01.html" rel="" target="">
    2021年1月(4)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/12.html" rel="" target="">
    2020年12月(4)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/11.html" rel="" target="">
    2020年11月(3)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/10.html" rel="" target="">
    2020年10月(4)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/09.html" rel="" target="">
    2020年9月(9)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/08.html" rel="" target="">
    2020年8月(10)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/07.html" rel="" target="">
    2020年7月(6)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/06.html" rel="" target="">
    2020年6月(3)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/05.html" rel="" target="">
    2020年5月(9)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2020/01.html" rel="" target="">
    2020年1月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2019/12.html" rel="" target="">
    2019年12月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2019/11.html" rel="" target="">
    2019年11月(2)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2019/10.html" rel="" target="">
    2019年10月(3)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2019/06.html" rel="" target="">
    2019年6月(2)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2019/05.html" rel="" target="">
    2019年5月(12)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2019/04.html" rel="" target="">
    2019年4月(2)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2019/03.html" rel="" target="">
    2019年3月(3)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2019/01.html" rel="" target="">
    2019年1月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/12.html" rel="" target="">
    2018年12月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/11.html" rel="" target="">
    2018年11月(2)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/10.html" rel="" target="">
    2018年10月(2)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/09.html" rel="" target="">
    2018年9月(13)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/08.html" rel="" target="">
    2018年8月(7)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/07.html" rel="" target="">
    2018年7月(10)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/06.html" rel="" target="">
    2018年6月(18)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/05.html" rel="" target="">
    2018年5月(10)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/04.html" rel="" target="">
    2018年4月(8)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/03.html" rel="" target="">
    2018年3月(6)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2018/01.html" rel="" target="">
    2018年1月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/12.html" rel="" target="">
    2017年12月(13)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/11.html" rel="" target="">
    2017年11月(6)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/10.html" rel="" target="">
    2017年10月(8)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/09.html" rel="" target="">
    2017年9月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/07.html" rel="" target="">
    2017年7月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/06.html" rel="" target="">
    2017年6月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/05.html" rel="" target="">
    2017年5月(2)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/04.html" rel="" target="">
    2017年4月(5)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/03.html" rel="" target="">
    2017年3月(31)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/02.html" rel="" target="">
    2017年2月(29)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2017/01.html" rel="" target="">
    2017年1月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2016/12.html" rel="" target="">
    2016年12月(17)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2016/11.html" rel="" target="">
    2016年11月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2016/10.html" rel="" target="">
    2016年10月(4)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2016/09.html" rel="" target="">
    2016年9月(13)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2016/08.html" rel="" target="">
    2016年8月(39)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2016/06.html" rel="" target="">
    2016年6月(7)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2016/03.html" rel="" target="">
    2016年3月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="false" style="display: none">
                
<a href="https://www.cnblogs.com/liushui-sky/archive/2012/02.html" rel="" target="">
    2012年2月(1)
</a>


            </li>                <li class="catListItem"><a href="javascript:void(0)" onclick="sideColumnManager.loadMore(this)">更多</a></li>
    </ul>
    <h3 class="catListTitle">
        
文章分类



    </h3>
    <ul class="catList">
            <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/category/1863207.html" rel="" target="">
    http(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/category/1277716.html" rel="" target="">
    Qt(6)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/category/1263727.html" rel="" target="">
    webservice(2)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/category/1279671.html" rel="" target="">
    编译技术(3)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/category/790249.html" rel="" target="">
    数据库(1)
</a>


            </li>                
    </ul>
    <h3 class="catListTitle">
        
文章档案



    </h3>
    <ul class="catList">
            <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archives/2020/12.html" rel="nofollow noopener noreferrer" target="">
    2020年12月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archives/2020/10.html" rel="nofollow noopener noreferrer" target="">
    2020年10月(1)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archives/2018/09.html" rel="nofollow noopener noreferrer" target="">
    2018年9月(2)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archives/2018/08.html" rel="nofollow noopener noreferrer" target="">
    2018年8月(8)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archives/2018/07.html" rel="nofollow noopener noreferrer" target="">
    2018年7月(5)
</a>


            </li>                    <li class="catListItem" data-category-list-item-visible="true" style="display: block">
                
<a href="https://www.cnblogs.com/liushui-sky/archives/2016/02.html" rel="nofollow noopener noreferrer" target="">
    2016年2月(1)
</a>


            </li>                
    </ul>
</div>

<!-- 最新评论 -->
<div id="sidebar_recentcomments" class="sidebar-block"><div id="recent_comments_wrap" class="RecentComment">
    <h3 class="catListTitle">最新评论</h3>
    <div class="RecentCommentBlock">
        <ul>
                    <li class="recent_comment_title"><a href="https://www.cnblogs.com/liushui-sky/p/10025732.html">1. Re:C语言——数组名、取数组首地址的区别（一）</a></li>
                    <li class="recent_comment_body"><p>好文，谢谢楼主的总结，豁然开朗！</p>
</li>
                    <li class="recent_comment_author">--折木家的招财猫</li>
                    <li class="recent_comment_title"><a href="https://www.cnblogs.com/liushui-sky/p/8563265.html">2. Re:去除QT不使用参数的警告</a></li>
                    <li class="recent_comment_body"><p>可以！棒</p>
</li>
                    <li class="recent_comment_author">--wang444455555</li>
                    <li class="recent_comment_title"><a href="https://www.cnblogs.com/liushui-sky/p/13528788.html">3. Re:瞧一瞧Qt的QMutex</a></li>
                    <li class="recent_comment_body"><p>谢谢博主的精彩图文讲解</p>
</li>
                    <li class="recent_comment_author">--扁舟伊雨农</li>
                    <li class="recent_comment_title"><a href="https://www.cnblogs.com/liushui-sky/p/5829563.html">4. Re:重点：怎样正确的使用QThread类（注：包括推荐使用QThread线程的新方法QObject::moveToThread）</a></li>
                    <li class="recent_comment_body"><p><strong>谢谢大佬 赞！</strong></p>
</li>
                    <li class="recent_comment_author">--光怪鹿梨</li>
                    <li class="recent_comment_title"><a href="https://www.cnblogs.com/liushui-sky/p/9202189.html">5. Re:debian linux 中如何查看软件包是否已经安装和如何安装、卸载软件</a></li>
                    <li class="recent_comment_body"><p>真乱</p>
</li>
                    <li class="recent_comment_author">--mystery-V</li>
        </ul>
    </div>
</div></div>


<!-- 阅读排行榜 -->
<div id="sidebar_topviewedposts" class="sidebar-block">
<div id="topview_posts_wrap">
    <h3 class="catListTitle">阅读排行榜</h3>
    <div id="TopViewPostsBlock">
        <ul style="word-break:break-all">
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/9203657.html">
                            1. linux时间同步，ntpd、ntpdate(188293)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/9962123.html">
                            2. CRC码计算及校验原理的最通俗诠释(94312)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/5802981.html">
                            3. C++类中this指针的理解(82807)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/5824919.html">
                            4. C++中基类的析构函数为什么要用virtual虚析构函数(38081)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/6560286.html">
                            5. QVariant类及QVariant与自定义数据类型转换的方法(34007)
                        </a>
                    </li>
        </ul>
    </div>
</div></div>

<!-- 评论排行榜 -->
<div id="sidebar_topcommentedposts" class="sidebar-block"><div id="topfeedback_posts_wrap">
    <h3 class="catListTitle">评论排行榜</h3>
    <div id="TopFeedbackPostsBlock">
        <ul style="word-break:break-all">
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/7850759.html">
                            1. 关于qt QWebKit/QWebview 使用心得(11)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/9962123.html">
                            2. CRC码计算及校验原理的最通俗诠释(6)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/7852361.html">
                            3. Qt 程序打包发布总结(6)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/5802981.html">
                            4. C++类中this指针的理解(4)
                        </a>
                    </li>
                    <li>
                        <a href="https://www.cnblogs.com/liushui-sky/p/7727865.html">
                            5. C++中内存泄漏的几种情况(3)
                        </a>
                    </li>
        </ul>
    </div>
</div></div>

<!-- 推荐排行榜 -->
<div id="sidebar_topdiggedposts" class="sidebar-block">
<div id="topdigg_posts_wrap">
    <div class="catListView">
        <h3 class="catListTitle">推荐排行榜</h3>
        <div id="TopDiggPostsBlock">
            <ul style="word-break: break-all">
                        <li>
                            <a href="https://www.cnblogs.com/liushui-sky/p/5802981.html">
                                1. C++类中this指针的理解(16)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/liushui-sky/p/9962123.html">
                                2. CRC码计算及校验原理的最通俗诠释(12)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/liushui-sky/p/5824919.html">
                                3. C++中基类的析构函数为什么要用virtual虚析构函数(12)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/liushui-sky/p/9203657.html">
                                4. linux时间同步，ntpd、ntpdate(9)
                            </a>
                        </li>
                        <li>
                            <a href="https://www.cnblogs.com/liushui-sky/p/7728902.html">
                                5. C++中构造函数，拷贝构造函数和赋值函数的区别和实现(5)
                            </a>
                        </li>
            </ul>
        </div>
    </div>
</div></div></div>
                    <script>loadBlogSideColumn();</script></div>
	
</div>
<!--done-->
<div class="footer">
	Powered by: <a href="http://www.cnblogs.com/">博客园</a>
	Copyright © 2021 苦涩的茶
<br><span id="poweredby">Powered by .NET 5.0 on Kubernetes</span>

</div>






    

    <input type="hidden" id="antiforgery_token" value="CfDJ8NACB8VE9qlHm6Ujjqxvg5DVkmaPo8LNe-xokigumdoZIDBwA7-g_bx59ctHMG3Vn3vs5-vSH12NOzsbErMg8mjT1KxBKSn-0LDJ5Rx10Q4IAe9HcL0jPurw9X4jBM8h5iRsG5ytRhEHMpY6l3XD_OY">


</body></html>